package b.h.b;

import b.f.h;
import b.i.j.c;
import java.util.ArrayList;
import java.util.HashSet;

/* compiled from: DirectedAcyclicGraph */
public final class a<T> {
    public final c<ArrayList<T>> a = new c(10);
    public final h<T, ArrayList<T>> b = new h();
    public final ArrayList<T> c = new ArrayList();
    public final HashSet<T> d = new HashSet();

    public void a(T t) {
        if ((this.b.e(t) >= 0 ? 1 : null) == null) {
            this.b.put(t, null);
        }
    }

    public final void b(T t, ArrayList<T> arrayList, HashSet<T> hashSet) {
        if (!arrayList.contains(t)) {
            if (hashSet.contains(t)) {
                throw new RuntimeException("This graph contains cyclic dependencies");
            }
            hashSet.add(t);
            ArrayList arrayList2 = (ArrayList) this.b.getOrDefault(t, null);
            if (arrayList2 != null) {
                int size = arrayList2.size();
                for (int i = 0; i < size; i++) {
                    b(arrayList2.get(i), arrayList, hashSet);
                }
            }
            hashSet.remove(t);
            arrayList.add(t);
        }
    }
}
